using System;
using NyMPH.Persistence;

public class PatchFile
{
	private string _location;
	private PatchData _data;
	private bool _modified;


    #region Properties
   
    /// <summary>
    /// This is the full path name of the Patch File.
    /// </summary>
    public string Location
    {
        set { _location = value; }
        get { return _location; }
    }

    /// <summary>
    /// The data contained in this Patch File
    /// </summary>
    public PatchData Data
    {
        set { _data = value; }
        get { return _data; }
    }

    /// <summary>
    /// True if this Patch File has been modified since it was last written to the file system, otherwise false.
    /// This is used for the File Watching feature.
    /// </summary>
    public bool Modified
    {
        set { _modified = value; }
        get { return _modified; }
    } 
    #endregion


    #region Methods

    /// <summary>
    /// Save this instance of a Patch File to the given Location
    /// </summary>
    /// <param name="Location">A directory and filename to save this patch file to</param>
    /// <returns>True if successful, otherwise false.</returns>
    public bool Save(string Location)
    {
        //todo: real basic implementation.
        FileSystem.Write(Location, _data.Data);
        throw new NotImplementedException("TODO:");
    }

    /// <summary>
    /// Save this instance of a Patch File to the path specified in the Location Property
    /// </summary>    
    /// <returns>True if successful, otherwise false.</returns>
    public bool Save()
    {
        //call overload
        return this.Save(_location);
    }

    /// <summary>
    /// Load this instance of a Patch File from the given Location
    /// </summary>
    /// <param name="Location">A directory and filename to load this patch file from.</param>
    /// <returns>True if successful, otherwise false.</returns>
    public PatchFile Load(string Location)
    {
        // TODO add implementation and return statement
        //TODO: validate file existence, content
        throw new NotImplementedException("TODO:");
    }

    /// <summary>
    /// If the PatchFile has been modified since being persisted.
    /// </summary>
    /// <returns>True if the Patch File has been modified, otherwise false.</returns>
    public bool IsModified()
    {
        // TODO add implementation and return statement
        throw new NotImplementedException("TODO:");
    }

    /// <summary>
    /// Set File Watching for this Patch File.
    /// </summary>
    /// <returns></returns>
    public bool SetFileWatch()
    {
        // TODO add implementation and return statement
        throw new NotImplementedException("TODO:");
    }

    /// <summary>
    /// Delete the actual file represented by this Patch File instance.
    /// </summary>
    /// <returns></returns>
    public bool Delete()
    {
        //todo: real basic implementation
        return FileSystem.Delete(_location);
    }

    #endregion


}
